package com.etoak.aspect;


import com.etoak.mapper.UserMapper;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class VisitAspect {

    @Autowired
    UserMapper userMapper;

    @Pointcut("execution(* com.etoak.service..*.*(..))")
    public void etoak(){}

    @Before("etoak()")
    public Object before(JoinPoint joinPoint){

        Object[] args = joinPoint.getArgs();
        int id = (int) args[0];
        userMapper.updateVisit(id);
        return args;
    }

}
